package com.run.motion.controller;

import java.util.List;

import com.run.motion.entity.GymEquipment;
import com.run.motion.service.IGymEquipmentService;
import com.run.motion.util.page.AjaxResult;
import com.run.motion.util.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 健身器材Controller
 * 
 * @author lyq
 * @date 2022-03-26
 */
@Api(tags = "健身器材")
@RestController
@RequestMapping("/gym/equipment")
public class GymEquipmentController extends BaseController
{
    @Autowired
    private IGymEquipmentService gymEquipmentService;

    /**
     * 查询健身器材列表
     */
    @ApiOperation(value = "查询健身器材列表")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<GymEquipment> list = gymEquipmentService.selectGymEquipmentList();
        return getDataTable(list);
    }



    /**
     * 获取健身器材详细信息
     */
    @ApiOperation(value = "获取健身器材详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gymEquipmentService.selectGymEquipmentById(id));
    }

    /**
     * 新增健身器材
     */
    @ApiOperation(value = "新增健身器材")
    @PostMapping
    public AjaxResult add(@RequestBody GymEquipment gymEquipment)
    {
        return toAjax(gymEquipmentService.insertGymEquipment(gymEquipment));
    }

    /**
     * 修改健身器材
     */
    @ApiOperation(value = "修改健身器材")
    @PutMapping
    public AjaxResult edit(@RequestBody GymEquipment gymEquipment)
    {
        return toAjax(gymEquipmentService.updateGymEquipment(gymEquipment));
    }

    /**
     * 删除健身器材
     */
    @ApiOperation(value = "删除健身器材")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gymEquipmentService.deleteGymEquipmentByIds(ids));
    }
}
